//首页推荐的两个选项按钮

// import { useReducer,useContext } from 'react'
import Taro from '@tarojs/taro'
import {  View,Image,Text } from '@tarojs/components'
import { useState } from 'react'
import { AtButton,AtIcon } from 'taro-ui'
import sortIcon from '../../images/sortIcon.png'
import './index.scss'


export default function ChooseBUttons(props){
// const openid=props.openid
const [isSelect,setIsselect]=useState(true)

  const chooseByTime=()=>{

    if(!Taro.getStorageSync(`openid`)){
    }else{
      props.setPage()
      props.userValue('byTime')
      setIsselect(!isSelect)
    }
  }


  const chooseBySal=()=>{
    // if(!Taro.getStorageSync(`openid`)){
    //   Taro.showToast({
    //     title: '请先登录',
    //     icon: 'error',
    //     duration: 1500
    //   })
    // }else{
      props.setPage()
      props.userValue('bySal')  
      setIsselect(!isSelect)
    // }
  }

  return (
    <View>
      <View className='order'>


      <View className='sortIcon'>
      <Text className='orderText'>排序</Text>
      <View className='imgBox'> <Image className='sortIconimg' src={sortIcon}></Image></View>
      </View>

      <AtButton className={['orderButton',isSelect?null:"selected"]} circle  size='small' onClick={chooseBySal}>薪资最高</AtButton>
      <AtButton className={['orderButton',isSelect?"selected":null]} circle  size='small' onClick={chooseByTime}>最新发布</AtButton>
      </View>

    </View>
  )
}